<?php

namespace pmvc\annotation;

use Exception;
use stdClass;

class AnnotationLexer {

	const TOKEN_ANNOTATION_CLASS	= "TOKEN_ANNOTATION_CLASS";
	const TOKEN_VAR_NAME			= "TOKEN_VAR_NAME";
	const TOKEN_VAR_INT				= "TOKEN_VAR_INT";
	const TOKEN_VAR_FLOAT			= "TOKEN_VAR_FLOAT";
	const TOKEN_VAR_BOOL			= "TOKEN_VAR_BOOL";
	const TOKEN_VAR_STRING			= "TOKEN_VAR_STRING";
	const TOKEN_VAR_CONST			= "TOKEN_VAR_CONST";
	const TOKEN_VAR_NULL			= "TOKEN_VAR_NULL";
	const TOKEN_VAR_ARRAY_START		= "TOKEN_VAR_ARRAY_START";
	const TOKEN_VAR_ARRAY_END		= "TOKEN_VAR_ARRAY_END";
	const TOKEN_ANNOTATION			= "TOKEN_ANNOTATION";
	const TOKEN_ANNOTATION_FINISHED	= "TOKEN_ANNOTATION_FINISHED";
	const TOKEN_IGNORE				= "TOKEN_IGNORE";

	public $counter;
	public $data;
	public $token;
	public $value;
	public $line;
	public $type;
	
	public function __construct($data) {
		$this->data 		= $data . "\n"; //now all lines are \n-terminated
		$this->counter 		= 0;
		$this->line 		= 1;
		$this->type			= "";
	}

	public function getState() {
		return $this->_yy_state;
	}

	public function nextToken() {

		// get the token
		$val = true;
		do {
			if (!$this->yylex()) {
				return false;
			}
		} while($this->type==self::TOKEN_IGNORE);

		// create the token
		$token = new stdClass();
		$token->type	= $this->type;
		$token->number	= $this->token;
		$token->value	= $this->value;
		$token->line	= $this->line;
		$token->counter	= $this->counter;
		$token->state	= $this->_yy_state;

		// reset the type
		$this->type	= "";

		// return it
		return $token;
	}


    private $_yy_state = 1;
    private $_yy_stack = array();

    function yylex()
    {
        return $this->{'yylex' . $this->_yy_state}();
    }

    function yypushstate($state)
    {
        array_push($this->_yy_stack, $this->_yy_state);
        $this->_yy_state = $state;
    }

    function yypopstate()
    {
        $this->_yy_state = array_pop($this->_yy_stack);
    }

    function yybegin($state)
    {
        $this->_yy_state = $state;
    }




    function yylex1()
    {
        $tokenMap = array (
              1 => 0,
              2 => 0,
              3 => 0,
              4 => 0,
              5 => 0,
            );
        if ($this->counter >= strlen($this->data)) {
            return false; // end of input
        }
        $yy_global_pattern = '/\G(\/\\*\\*)|\G([ \t\r]+\\*\/)|\G([ \t\r]*\\*[^\/])|\G([ \t\r]+)|\G(\n)/';

        do {
            if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
                $yysubmatches = $yymatches;
                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                if (!count($yymatches)) {
                    throw new Exception('Error: lexing failed because a rule matched' .
                        ' an empty string.  Input "' . substr($this->data,
                        $this->counter, 5) . '... state WAIT');
                }
                next($yymatches); // skip global match
                $this->token = key($yymatches); // token number
                if ($tokenMap[$this->token]) {
                    // extract sub-patterns for passing to lex function
                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                        $tokenMap[$this->token]);
                } else {
                    $yysubmatches = array();
                }
                $this->value = current($yymatches); // token value
                $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
                if ($r === null) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    // accept this token
                    return true;
                } elseif ($r === true) {
                    // we have changed state
                    // process this token in the new state
                    return $this->yylex();
                } elseif ($r === false) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    if ($this->counter >= strlen($this->data)) {
                        return false; // end of input
                    }
                    // skip this token
                    continue;
                } else {
                    $yy_yymore_patterns = array(
        1 => array(0, "\G([ \t\r]+\\*\/)|\G([ \t\r]*\\*[^\/])|\G([ \t\r]+)|\G(\n)"),
        2 => array(0, "\G([ \t\r]*\\*[^\/])|\G([ \t\r]+)|\G(\n)"),
        3 => array(0, "\G([ \t\r]+)|\G(\n)"),
        4 => array(0, "\G(\n)"),
        5 => array(0, ""),
    );

                    // yymore is needed
                    do {
                        if (!strlen($yy_yymore_patterns[$this->token][1])) {
                            throw new Exception('cannot do yymore for the last token');
                        }
                        $yysubmatches = array();
                        if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/',
                              $this->data, $yymatches, null, $this->counter)) {
                            $yysubmatches = $yymatches;
                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                            next($yymatches); // skip global match
                            $this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number
                            $this->value = current($yymatches); // token value
                            $this->line = substr_count($this->value, "\n");
                            if ($tokenMap[$this->token]) {
                                // extract sub-patterns for passing to lex function
                                $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                                    $tokenMap[$this->token]);
                            } else {
                                $yysubmatches = array();
                            }
                        }
                        $r = $this->{'yy_r1_' . $this->token}($yysubmatches);
                    } while ($r !== null && !is_bool($r));
                    if ($r === true) {
                        // we have changed state
                        // process this token in the new state
                        return $this->yylex();
                    } elseif ($r === false) {
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        if ($this->counter >= strlen($this->data)) {
                            return false; // end of input
                        }
                        // skip this token
                        continue;
                    } else {
                        // accept
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        return true;
                    }
                }
            } else {
                throw new Exception('Unexpected input at line' . $this->line .
                    ': ' . $this->data[$this->counter]);
            }
            break;
        } while (true);

    } // end function


    const WAIT = 1;
    function yy_r1_1($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::DOCBLOCK);
    }
    function yy_r1_2($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
    }
    function yy_r1_3($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::DOCBLOCK);
    }
    function yy_r1_4($yy_subpatterns)
    {
 return false;     }
    function yy_r1_5($yy_subpatterns)
    {
 return false;     }



    function yylex2()
    {
        $tokenMap = array (
              1 => 0,
              2 => 0,
              3 => 0,
              4 => 0,
            );
        if ($this->counter >= strlen($this->data)) {
            return false; // end of input
        }
        $yy_global_pattern = '/\G(\n)|\G(@\\\\)|\G([ \t\r]+)|\G([\s\S])/';

        do {
            if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
                $yysubmatches = $yymatches;
                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                if (!count($yymatches)) {
                    throw new Exception('Error: lexing failed because a rule matched' .
                        ' an empty string.  Input "' . substr($this->data,
                        $this->counter, 5) . '... state DOCBLOCK');
                }
                next($yymatches); // skip global match
                $this->token = key($yymatches); // token number
                if ($tokenMap[$this->token]) {
                    // extract sub-patterns for passing to lex function
                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                        $tokenMap[$this->token]);
                } else {
                    $yysubmatches = array();
                }
                $this->value = current($yymatches); // token value
                $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
                if ($r === null) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    // accept this token
                    return true;
                } elseif ($r === true) {
                    // we have changed state
                    // process this token in the new state
                    return $this->yylex();
                } elseif ($r === false) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    if ($this->counter >= strlen($this->data)) {
                        return false; // end of input
                    }
                    // skip this token
                    continue;
                } else {
                    $yy_yymore_patterns = array(
        1 => array(0, "\G(@\\\\)|\G([ \t\r]+)|\G([\s\S])"),
        2 => array(0, "\G([ \t\r]+)|\G([\s\S])"),
        3 => array(0, "\G([\s\S])"),
        4 => array(0, ""),
    );

                    // yymore is needed
                    do {
                        if (!strlen($yy_yymore_patterns[$this->token][1])) {
                            throw new Exception('cannot do yymore for the last token');
                        }
                        $yysubmatches = array();
                        if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/',
                              $this->data, $yymatches, null, $this->counter)) {
                            $yysubmatches = $yymatches;
                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                            next($yymatches); // skip global match
                            $this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number
                            $this->value = current($yymatches); // token value
                            $this->line = substr_count($this->value, "\n");
                            if ($tokenMap[$this->token]) {
                                // extract sub-patterns for passing to lex function
                                $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                                    $tokenMap[$this->token]);
                            } else {
                                $yysubmatches = array();
                            }
                        }
                        $r = $this->{'yy_r2_' . $this->token}($yysubmatches);
                    } while ($r !== null && !is_bool($r));
                    if ($r === true) {
                        // we have changed state
                        // process this token in the new state
                        return $this->yylex();
                    } elseif ($r === false) {
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        if ($this->counter >= strlen($this->data)) {
                            return false; // end of input
                        }
                        // skip this token
                        continue;
                    } else {
                        // accept
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        return true;
                    }
                }
            } else {
                throw new Exception('Unexpected input at line' . $this->line .
                    ': ' . $this->data[$this->counter]);
            }
            break;
        } while (true);

    } // end function


    const DOCBLOCK = 2;
    function yy_r2_1($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypopstate();
    }
    function yy_r2_2($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::ANNOTATION);
    }
    function yy_r2_3($yy_subpatterns)
    {
 return false;     }
    function yy_r2_4($yy_subpatterns)
    {
 return false;     }



    function yylex3()
    {
        $tokenMap = array (
              1 => 0,
              2 => 0,
              3 => 0,
              4 => 0,
              5 => 0,
              6 => 0,
            );
        if ($this->counter >= strlen($this->data)) {
            return false; // end of input
        }
        $yy_global_pattern = '/\G(\n)|\G([A-Za-z0-9_\\\\]+)|\G(\\()|\G(\\))|\G([ \t\r]+)|\G([ \t\r]*\\*[^\/])/';

        do {
            if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
                $yysubmatches = $yymatches;
                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                if (!count($yymatches)) {
                    throw new Exception('Error: lexing failed because a rule matched' .
                        ' an empty string.  Input "' . substr($this->data,
                        $this->counter, 5) . '... state ANNOTATION');
                }
                next($yymatches); // skip global match
                $this->token = key($yymatches); // token number
                if ($tokenMap[$this->token]) {
                    // extract sub-patterns for passing to lex function
                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                        $tokenMap[$this->token]);
                } else {
                    $yysubmatches = array();
                }
                $this->value = current($yymatches); // token value
                $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
                if ($r === null) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    // accept this token
                    return true;
                } elseif ($r === true) {
                    // we have changed state
                    // process this token in the new state
                    return $this->yylex();
                } elseif ($r === false) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    if ($this->counter >= strlen($this->data)) {
                        return false; // end of input
                    }
                    // skip this token
                    continue;
                } else {
                    $yy_yymore_patterns = array(
        1 => array(0, "\G([A-Za-z0-9_\\\\]+)|\G(\\()|\G(\\))|\G([ \t\r]+)|\G([ \t\r]*\\*[^\/])"),
        2 => array(0, "\G(\\()|\G(\\))|\G([ \t\r]+)|\G([ \t\r]*\\*[^\/])"),
        3 => array(0, "\G(\\))|\G([ \t\r]+)|\G([ \t\r]*\\*[^\/])"),
        4 => array(0, "\G([ \t\r]+)|\G([ \t\r]*\\*[^\/])"),
        5 => array(0, "\G([ \t\r]*\\*[^\/])"),
        6 => array(0, ""),
    );

                    // yymore is needed
                    do {
                        if (!strlen($yy_yymore_patterns[$this->token][1])) {
                            throw new Exception('cannot do yymore for the last token');
                        }
                        $yysubmatches = array();
                        if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/',
                              $this->data, $yymatches, null, $this->counter)) {
                            $yysubmatches = $yymatches;
                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                            next($yymatches); // skip global match
                            $this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number
                            $this->value = current($yymatches); // token value
                            $this->line = substr_count($this->value, "\n");
                            if ($tokenMap[$this->token]) {
                                // extract sub-patterns for passing to lex function
                                $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                                    $tokenMap[$this->token]);
                            } else {
                                $yysubmatches = array();
                            }
                        }
                        $r = $this->{'yy_r3_' . $this->token}($yysubmatches);
                    } while ($r !== null && !is_bool($r));
                    if ($r === true) {
                        // we have changed state
                        // process this token in the new state
                        return $this->yylex();
                    } elseif ($r === false) {
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        if ($this->counter >= strlen($this->data)) {
                            return false; // end of input
                        }
                        // skip this token
                        continue;
                    } else {
                        // accept
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        return true;
                    }
                }
            } else {
                throw new Exception('Unexpected input at line' . $this->line .
                    ': ' . $this->data[$this->counter]);
            }
            break;
        } while (true);

    } // end function


    const ANNOTATION = 3;
    function yy_r3_1($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypopstate();
    }
    function yy_r3_2($yy_subpatterns)
    {

	$this->type = self::TOKEN_ANNOTATION_CLASS;
    }
    function yy_r3_3($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::ANNOTATION_VARS); // entered
    }
    function yy_r3_4($yy_subpatterns)
    {

	$this->type = self::TOKEN_ANNOTATION_FINISHED;
	$this->yypopstate();
    }
    function yy_r3_5($yy_subpatterns)
    {
 return false;     }
    function yy_r3_6($yy_subpatterns)
    {
 return false;     }



    function yylex4()
    {
        $tokenMap = array (
              1 => 0,
              2 => 0,
              3 => 0,
              4 => 0,
              5 => 0,
              6 => 0,
            );
        if ($this->counter >= strlen($this->data)) {
            return false; // end of input
        }
        $yy_global_pattern = '/\G([ \t\r]+)|\G(\n)|\G([ \t\r]*\\*[^\/])|\G(\\))|\G([A-Za-z0-9_]+)|\G(=)/';

        do {
            if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
                $yysubmatches = $yymatches;
                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                if (!count($yymatches)) {
                    throw new Exception('Error: lexing failed because a rule matched' .
                        ' an empty string.  Input "' . substr($this->data,
                        $this->counter, 5) . '... state ANNOTATION_VARS');
                }
                next($yymatches); // skip global match
                $this->token = key($yymatches); // token number
                if ($tokenMap[$this->token]) {
                    // extract sub-patterns for passing to lex function
                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                        $tokenMap[$this->token]);
                } else {
                    $yysubmatches = array();
                }
                $this->value = current($yymatches); // token value
                $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
                if ($r === null) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    // accept this token
                    return true;
                } elseif ($r === true) {
                    // we have changed state
                    // process this token in the new state
                    return $this->yylex();
                } elseif ($r === false) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    if ($this->counter >= strlen($this->data)) {
                        return false; // end of input
                    }
                    // skip this token
                    continue;
                } else {
                    $yy_yymore_patterns = array(
        1 => array(0, "\G(\n)|\G([ \t\r]*\\*[^\/])|\G(\\))|\G([A-Za-z0-9_]+)|\G(=)"),
        2 => array(0, "\G([ \t\r]*\\*[^\/])|\G(\\))|\G([A-Za-z0-9_]+)|\G(=)"),
        3 => array(0, "\G(\\))|\G([A-Za-z0-9_]+)|\G(=)"),
        4 => array(0, "\G([A-Za-z0-9_]+)|\G(=)"),
        5 => array(0, "\G(=)"),
        6 => array(0, ""),
    );

                    // yymore is needed
                    do {
                        if (!strlen($yy_yymore_patterns[$this->token][1])) {
                            throw new Exception('cannot do yymore for the last token');
                        }
                        $yysubmatches = array();
                        if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/',
                              $this->data, $yymatches, null, $this->counter)) {
                            $yysubmatches = $yymatches;
                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                            next($yymatches); // skip global match
                            $this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number
                            $this->value = current($yymatches); // token value
                            $this->line = substr_count($this->value, "\n");
                            if ($tokenMap[$this->token]) {
                                // extract sub-patterns for passing to lex function
                                $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                                    $tokenMap[$this->token]);
                            } else {
                                $yysubmatches = array();
                            }
                        }
                        $r = $this->{'yy_r4_' . $this->token}($yysubmatches);
                    } while ($r !== null && !is_bool($r));
                    if ($r === true) {
                        // we have changed state
                        // process this token in the new state
                        return $this->yylex();
                    } elseif ($r === false) {
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        if ($this->counter >= strlen($this->data)) {
                            return false; // end of input
                        }
                        // skip this token
                        continue;
                    } else {
                        // accept
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        return true;
                    }
                }
            } else {
                throw new Exception('Unexpected input at line' . $this->line .
                    ': ' . $this->data[$this->counter]);
            }
            break;
        } while (true);

    } // end function


    const ANNOTATION_VARS = 4;
    function yy_r4_1($yy_subpatterns)
    {
 return false;     }
    function yy_r4_2($yy_subpatterns)
    {
 return false;     }
    function yy_r4_3($yy_subpatterns)
    {
 return false;     }
    function yy_r4_4($yy_subpatterns)
    {

	$this->yypopstate();
	return true;
    }
    function yy_r4_5($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_NAME;
    }
    function yy_r4_6($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::ANNOTATION_VAR_VALUE); // entered
    }



    function yylex5()
    {
        $tokenMap = array (
              1 => 0,
              2 => 0,
              3 => 0,
              4 => 0,
              5 => 0,
              6 => 0,
              7 => 0,
              8 => 0,
              9 => 0,
              10 => 0,
              11 => 0,
              12 => 0,
              13 => 0,
              14 => 0,
            );
        if ($this->counter >= strlen($this->data)) {
            return false; // end of input
        }
        $yy_global_pattern = '/\G([ \t\r]+)|\G(\n)|\G([ \t\r]*\\*[^\/])|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)/';

        do {
            if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
                $yysubmatches = $yymatches;
                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                if (!count($yymatches)) {
                    throw new Exception('Error: lexing failed because a rule matched' .
                        ' an empty string.  Input "' . substr($this->data,
                        $this->counter, 5) . '... state ANNOTATION_VAR_VALUE');
                }
                next($yymatches); // skip global match
                $this->token = key($yymatches); // token number
                if ($tokenMap[$this->token]) {
                    // extract sub-patterns for passing to lex function
                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                        $tokenMap[$this->token]);
                } else {
                    $yysubmatches = array();
                }
                $this->value = current($yymatches); // token value
                $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
                if ($r === null) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    // accept this token
                    return true;
                } elseif ($r === true) {
                    // we have changed state
                    // process this token in the new state
                    return $this->yylex();
                } elseif ($r === false) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    if ($this->counter >= strlen($this->data)) {
                        return false; // end of input
                    }
                    // skip this token
                    continue;
                } else {
                    $yy_yymore_patterns = array(
        1 => array(0, "\G(\n)|\G([ \t\r]*\\*[^\/])|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        2 => array(0, "\G([ \t\r]*\\*[^\/])|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        3 => array(0, "\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        4 => array(0, "\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        5 => array(0, "\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        6 => array(0, "\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        7 => array(0, "\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        8 => array(0, "\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        9 => array(0, "\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        10 => array(0, "\G(@\\\\)|\G(\\[)|\G(\\))|\G(,)"),
        11 => array(0, "\G(\\[)|\G(\\))|\G(,)"),
        12 => array(0, "\G(\\))|\G(,)"),
        13 => array(0, "\G(,)"),
        14 => array(0, ""),
    );

                    // yymore is needed
                    do {
                        if (!strlen($yy_yymore_patterns[$this->token][1])) {
                            throw new Exception('cannot do yymore for the last token');
                        }
                        $yysubmatches = array();
                        if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/',
                              $this->data, $yymatches, null, $this->counter)) {
                            $yysubmatches = $yymatches;
                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                            next($yymatches); // skip global match
                            $this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number
                            $this->value = current($yymatches); // token value
                            $this->line = substr_count($this->value, "\n");
                            if ($tokenMap[$this->token]) {
                                // extract sub-patterns for passing to lex function
                                $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                                    $tokenMap[$this->token]);
                            } else {
                                $yysubmatches = array();
                            }
                        }
                        $r = $this->{'yy_r5_' . $this->token}($yysubmatches);
                    } while ($r !== null && !is_bool($r));
                    if ($r === true) {
                        // we have changed state
                        // process this token in the new state
                        return $this->yylex();
                    } elseif ($r === false) {
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        if ($this->counter >= strlen($this->data)) {
                            return false; // end of input
                        }
                        // skip this token
                        continue;
                    } else {
                        // accept
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        return true;
                    }
                }
            } else {
                throw new Exception('Unexpected input at line' . $this->line .
                    ': ' . $this->data[$this->counter]);
            }
            break;
        } while (true);

    } // end function


    const ANNOTATION_VAR_VALUE = 5;
    function yy_r5_1($yy_subpatterns)
    {
 return false;     }
    function yy_r5_2($yy_subpatterns)
    {
 return false;     }
    function yy_r5_3($yy_subpatterns)
    {
 return false;     }
    function yy_r5_4($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_FLOAT;
    }
    function yy_r5_5($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_INT;
    }
    function yy_r5_6($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_BOOL;
    }
    function yy_r5_7($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_STRING;
    }
    function yy_r5_8($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_STRING;
    }
    function yy_r5_9($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_CONST;
    }
    function yy_r5_10($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_NULL;
    }
    function yy_r5_11($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::ANNOTATION);
    }
    function yy_r5_12($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_ARRAY_START;
	$this->yypushstate(self::ANNOTATION_VAR_VALUE_ARRAY);
    }
    function yy_r5_13($yy_subpatterns)
    {

	$this->yypopstate();
	return true;
    }
    function yy_r5_14($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypopstate();
    }



    function yylex6()
    {
        $tokenMap = array (
              1 => 0,
              2 => 0,
              3 => 0,
              4 => 0,
              5 => 0,
              6 => 0,
              7 => 0,
              8 => 0,
              9 => 0,
              10 => 0,
              11 => 0,
              12 => 0,
              13 => 0,
              14 => 0,
            );
        if ($this->counter >= strlen($this->data)) {
            return false; // end of input
        }
        $yy_global_pattern = '/\G([ \t\r]+)|\G(\n)|\G([ \t\r]*\\*[^\/])|\G(,)|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])/';

        do {
            if (preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) {
                $yysubmatches = $yymatches;
                $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                if (!count($yymatches)) {
                    throw new Exception('Error: lexing failed because a rule matched' .
                        ' an empty string.  Input "' . substr($this->data,
                        $this->counter, 5) . '... state ANNOTATION_VAR_VALUE_ARRAY');
                }
                next($yymatches); // skip global match
                $this->token = key($yymatches); // token number
                if ($tokenMap[$this->token]) {
                    // extract sub-patterns for passing to lex function
                    $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                        $tokenMap[$this->token]);
                } else {
                    $yysubmatches = array();
                }
                $this->value = current($yymatches); // token value
                $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
                if ($r === null) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    // accept this token
                    return true;
                } elseif ($r === true) {
                    // we have changed state
                    // process this token in the new state
                    return $this->yylex();
                } elseif ($r === false) {
                    $this->counter += strlen($this->value);
                    $this->line += substr_count($this->value, "\n");
                    if ($this->counter >= strlen($this->data)) {
                        return false; // end of input
                    }
                    // skip this token
                    continue;
                } else {
                    $yy_yymore_patterns = array(
        1 => array(0, "\G(\n)|\G([ \t\r]*\\*[^\/])|\G(,)|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        2 => array(0, "\G([ \t\r]*\\*[^\/])|\G(,)|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        3 => array(0, "\G(,)|\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        4 => array(0, "\G(\\d+\\.\\d+)|\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        5 => array(0, "\G(\\d+)|\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        6 => array(0, "\G(true|false|TRUE|FALSE)|\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        7 => array(0, "\G(\"(?:[^\\\\\"]|\\\\.)*\")|\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        8 => array(0, "\G(\'(?:[^\\\']|\.)*\')|\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        9 => array(0, "\G([A-Za-z0-9_\\\\]+::[A-Za-z0-9_]+)|\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        10 => array(0, "\G(null|NULL)|\G(@\\\\)|\G(\\[)|\G(\\])"),
        11 => array(0, "\G(@\\\\)|\G(\\[)|\G(\\])"),
        12 => array(0, "\G(\\[)|\G(\\])"),
        13 => array(0, "\G(\\])"),
        14 => array(0, ""),
    );

                    // yymore is needed
                    do {
                        if (!strlen($yy_yymore_patterns[$this->token][1])) {
                            throw new Exception('cannot do yymore for the last token');
                        }
                        $yysubmatches = array();
                        if (preg_match('/' . $yy_yymore_patterns[$this->token][1] . '/',
                              $this->data, $yymatches, null, $this->counter)) {
                            $yysubmatches = $yymatches;
                            $yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
                            next($yymatches); // skip global match
                            $this->token += key($yymatches) + $yy_yymore_patterns[$this->token][0]; // token number
                            $this->value = current($yymatches); // token value
                            $this->line = substr_count($this->value, "\n");
                            if ($tokenMap[$this->token]) {
                                // extract sub-patterns for passing to lex function
                                $yysubmatches = array_slice($yysubmatches, $this->token + 1,
                                    $tokenMap[$this->token]);
                            } else {
                                $yysubmatches = array();
                            }
                        }
                        $r = $this->{'yy_r6_' . $this->token}($yysubmatches);
                    } while ($r !== null && !is_bool($r));
                    if ($r === true) {
                        // we have changed state
                        // process this token in the new state
                        return $this->yylex();
                    } elseif ($r === false) {
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        if ($this->counter >= strlen($this->data)) {
                            return false; // end of input
                        }
                        // skip this token
                        continue;
                    } else {
                        // accept
                        $this->counter += strlen($this->value);
                        $this->line += substr_count($this->value, "\n");
                        return true;
                    }
                }
            } else {
                throw new Exception('Unexpected input at line' . $this->line .
                    ': ' . $this->data[$this->counter]);
            }
            break;
        } while (true);

    } // end function


    const ANNOTATION_VAR_VALUE_ARRAY = 6;
    function yy_r6_1($yy_subpatterns)
    {
 return false;     }
    function yy_r6_2($yy_subpatterns)
    {
 return false;     }
    function yy_r6_3($yy_subpatterns)
    {
 return false;     }
    function yy_r6_4($yy_subpatterns)
    {
 return false;     }
    function yy_r6_5($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_FLOAT;
    }
    function yy_r6_6($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_INT;
    }
    function yy_r6_7($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_BOOL;
    }
    function yy_r6_8($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_STRING;
    }
    function yy_r6_9($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_STRING;
    }
    function yy_r6_10($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_CONST;
    }
    function yy_r6_11($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_NULL;
    }
    function yy_r6_12($yy_subpatterns)
    {

	$this->type = self::TOKEN_IGNORE;
	$this->yypushstate(self::ANNOTATION);
    }
    function yy_r6_13($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_ARRAY_START;
	$this->yypushstate(self::ANNOTATION_VAR_VALUE_ARRAY);
    }
    function yy_r6_14($yy_subpatterns)
    {

	$this->type = self::TOKEN_VAR_ARRAY_END;
	$this->yypopstate();
    }


}
?>